DevForce Help Reference
EntitySpan Constructor(Type,EntityRelation[])
Example 


Root Entity type
One or more entity relations
Initializes a new instance of the EntitySpan class.
Syntax
'Declaration
 
Public Function New( _
   ByVal fromType As Type, _
   ByVal ParamArray entityRelations() As EntityRelation _
)
'Usage
 
Dim fromType As Type
Dim entityRelations() As EntityRelation
 
Dim instance As New EntitySpan(fromType, entityRelations)
public EntitySpan( 
   Type fromType,
   params EntityRelation[] entityRelations
)

Parameters

fromType
Root Entity type
entityRelations
One or more entity relations
Exceptions
ExceptionDescription
System.ArgumentExceptionThrown if the relationships are ambiguous or do not connect
Remarks
A single EntitySpan represents the relations among a graph of entities. You must be able to "walk" the spans without jumping or backtracking.

The EntitySpan is used in retrieving an entity graph with EntityManager.FindEntityGraph

Example
public void FindEntityGraph() {

  DomainModelEntityManager mgr = new DomainModelEntityManager();
  
  // Preload some data into cache for this example.
  var emp = mgr.Employees.Where(e => e.Id == 1).Include("OrderSummaries.OrderDetails.Product").ToList().First();

  // Get a product for this example.
  Product p = mgr.FindEntities<Product>(EntityState.Unchanged).First();


  // Now retrieve an object graph for the selected product.
  var roots = new List<Entity> { p };

  // Add spans - we want any order details using this product, their orders, and the employees.
  // Note you must be able to "walk" all relations in the single EntitySpan, if you can't then
  // you should use additional EntitySpans.
  EntitySpan span1 = new EntitySpan(typeof(Product), 
    EntityRelations.FK_Order_Details_Products, 
    EntityRelations.FK_Order_Details_Orders, 
    EntityRelations.FK_OrderSummary_Employee);

  var spans = new List<EntitySpan> { span1 };

  // Get the entity graph
  var entityGraph = mgr.FindEntityGraph(roots, spans, EntityState.Unchanged);

}
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

EntitySpan Class
EntitySpan Members
Overload List

Send Feedback